package com.shengqiang.zhenhuiTransfer.controller;

import com.shengqiang.zhenhuiTransfer.entity.Order;
import com.shengqiang.zhenhuiTransfer.entity.Result;
import com.shengqiang.zhenhuiTransfer.service.OrderService;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "addOrder")
    public Result<String> addOrder(@RequestBody Order order){
        return orderService.addOrder(order);
    }

    @RequestMapping(value = "updateOrder")
    public Result<String> updateOrder(@RequestBody Order order){
        return orderService.updateOrder(order);
    }

    @RequestMapping(value = "queryCurrentDay")
    public Result<List<Order>> queryCurrentDay(String date,String openId){
        return orderService.queryCurrenDayOrders(date,openId);
    }

    @RequestMapping(value = "queryMonthOrders")
    public Result<Map<String,Object>> queryMonthOrders(String date,String openId){
        return orderService.queryMonthOrders(date,openId);
    }
}
